<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" session="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <title>红包报表</title>

    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/css/select2.min.css"
          rel="stylesheet">
    <!-- jqgrid-->
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/custom.ui.jqgrid.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/style.css" rel="stylesheet">

    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/i18n/grid.locale-cn.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/minified/jquery.jqGrid.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/static/js/global.js"></script>
	<script src="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/js/select2.min.js"></script>
	<script type="text/javascript"
            src="${pageContext.request.contextPath}/static/plugins/My97DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        .main h5 a {
            position: absolute;
            right: 20px;
            font-size: 14px;
            bottom: 0px;
            display: inline-block;
            padding: 5px;
        }

        .table_list tbody tr {
            height: 35px;
            text-align: center;
        }
        .butt{
        	width: 100px;
		}
		
	
		.lt,.col-sm-3,.col-sm-8{float:left}
		.form-group{*+overflow:hidden;}
		.form-group label{width:31%\9;*+width:22%;text-align:right\9;*+text-align:right;}
		.col-sm-8 .m-t2 {width:30%\9; *+width:36%;}
		.form-group .col-sm-8{width:66%\9;*+width:66%;}
		.form-group .form-control{*+width:95%;}
		.form-control{*+height:22px;}
		#sub{*+margin-right:10px;}
		.input-group .form-control{*+z-index:-1;}
		.upload{*+position:relative;}
		.btn-primary{*+position:absolute;*+left:431px;*+top:-35px;*+z-index:3;}
    </style>
</head>
<body view="menu-item-4142">
<div style="margin-left: 10px;padding: 0px 10px 0 10px;">
 	<div class="wrapper">
	    <div class="jqGrid_wrapper">
	        <div id="jqGrid_operation" class="jg-grid">
	            <h1 id="rname1">红包发放记录</h1>
	            <div class="jqGrid_operation" id="action"></div>
	        </div>
	        <table id="jqGrid"></table>
	        <div id="jqGrid_paper"></div>
	    </div>
	</div>
</div>
<script>
if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
    var len = this.length >>> 0;
    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;
    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  }
};
    $(document).ready(
            function () {
                $("#rname1").html('${rName}'+" 红包发放记录");
                $.jgrid.defaults.styleUI = "Bootstrap";
                $("#jqGrid").jqGrid({
                      url: "${pageContext.request.contextPath}/admin/redPacket_sendRedNotes.action?ruleId="+'${ruleId}',
                      mtype: 'POST',
                      datatype: "json",
                      height: 350,
                      autowidth: true,
                      shrinkToFit: true,
                      rowNum: 10,
                      rowList: [10, 20, 30],
                      colNames: ['序号','合作方名称', '小区名称', '门禁PID', '门禁名称', '红包名称',
                          '用户手机号', '红包金额', '开门时间'],
                      colModel: [{
                          name: "SID",
                          index: "SID",
                          key: true,
                          hidden: true
                      }, {
                          name: 'AGTNAME',
                          index: 'AGTNAME'
                      }, {
                          name: 'COMMUNITYNAME',
                          index: 'COMMUNITYNAME'
                      }, {
                          name: 'PID',
                          index: 'PID'
                      },{
                          name: 'LOCKNAME',
                          index: 'LOCKNAME'
                      },{
                          name: 'RNAME',
                          index: 'RNAME'
                      }, {
                          name: "TEL",
                          index: "TEL"
                      }, {
                          name: "AMOUNT",
                          index: "AMOUNT"
                      }, {
                          name: "CTIME",
                          index: "CTIME",
                          width: 180
                      }],
                      sortname: 'sid',
                      sortorder:'desc',
                      rownumbers: true,
                      jsonReader: {
                          root: 'rows',
                          page: "page",
                          total: 'total',
                          records: "records",
                          repeatitems: false
                      },
                      pager: "#jqGrid_paper",
                      viewrecords: true,
                      multiselect: false,
                      hidegrid: false,
                      loadComplete: function(){
                    		var re_records = Number($("#jqGrid").getGridParam('records'));
                    		var page = Number($("#jqGrid").getGridParam('page'));
                    		var rows=Number($("#jqGrid").getGridParam('rowNum'));
                    		var num = re_records-(page-1)*rows;
                    		if(num < rows)
                    		{
                    			for(var i=num;i<rows;i++){
                    				$("#jqGrid").jqGrid("addRowData",(i+1),
                            				{ "SID":"", "AGTNAME":"", "COMMUNITYNAME":"", "PID":"", "LOCKNAME":"","RNAME":"","TEL":"","AMOUNT":"","CTIME":""}
                    				,"");
                    			}
                    			$(".ui-paging-info").html(re_records-num+1 +" - "+re_records+"　共 "+re_records+" 条");
                    		}
                    	}
                  });
                <!--查询-->
                jQuery("#query").click(query);
                jQuery("#resetForm").click(resetForm);
            });

    <!--刷新jqGrid表格数据-->
    function refreshGrid() {
        $("#jqGrid").trigger("reloadGrid");
    }
    function resetForm() {
        location.reload();
        return false;
    }
    
    function query() {
        var $agtCode = $("#agtCode").val();
        var $communityId = $("#communityId").val();
        var $rName = $("#rName").val();
        var $cbName = $("#cbName").val();
        var $pid = $("#pid").val();
        var $tel = $("#tel").val();
        var $ptime1 = $("#ptime1").val();
        var $ptime2 = $("#ptime2").val();
        $("#jqGrid").jqGrid('setGridParam', {
            url: "${pageContext.request.contextPath}/admin/redPacket_sendRedNotes.action",
            postData: {
                'agtCode': $agtCode,
                'communityId': $communityId,
                'rName': $rName,
                'cbName': $cbName,
                'pid': $pid,
                'tel': $tel,
                'ptime1': $ptime1,
                'ptime2': $ptime2
            }, //发送数据
            page: 1
        }).trigger("reloadGrid"); //重新载入*/
        return false;
    }
    
</script>
</body>
</html>
